﻿Public Class FrmCcapRealAlarm

    ''' <summary>
    ''' 所在项目的项目编号
    ''' </summary>
    Private _ProjectId As String

    ''' <summary>
    ''' 读取数据的偏移地址
    ''' </summary>
    Private _offset As UShort = 30000

    ''' <summary>
    ''' 最大报警记录
    ''' </summary>
    Private ReadOnly _MaxCount As Integer = 25

    ''' <summary>
    ''' 每条报警记录大小
    ''' </summary>
    Private ReadOnly _RecordSize As Integer = 10

    ''' <summary>
    ''' 每次读取数据的长度
    ''' </summary>
    Private _DataLength As UShort = _MaxCount * _RecordSize / 2

    ''' <summary>
    ''' 从下位机读取的数据
    ''' </summary>
    Private _Buf() As Byte

    ''CM 板的NetID
    Private _DevNetID As Byte = 255

    ''' <summary>
    ''' 窗体是否处于关闭中
    ''' </summary>
    Private _IsColsing As Boolean = False

    ''' <summary>
    ''' 正在进行确认
    ''' </summary>
    Private _IsConfirming As Boolean = False

    ''' <summary>
    ''' 正在进行刷新数据
    ''' </summary>
    Private _IsRefreshing As Boolean = False

    ''' <summary>
    ''' 保存的设备及端口名称
    ''' </summary>
    Private _Devices As Hashtable

    ''' <summary>
    ''' 连续通讯失败次数
    ''' </summary>
    Private _FailCount As Integer = 0

    ''' <summary>
    ''' 接受的数据转换成数据源
    ''' </summary>
    Private _DataSource As DataTable = Nothing
    ''' <summary>
    ''' 保存设备名称及端口
    ''' </summary>
    ''' <remarks></remarks>
    Friend Structure DeviceAndPort
        Public DeviceName As String
        Public AlarmName As String
        Public Port As Integer
        Public NetId As Integer
        Public IsAI As Boolean
    End Structure


    Public Sub New(ByVal projectId As String)
        _ProjectId = projectId
        InitializeComponent()
        InitDataSource()

        InitDevicesAndPorts()
        Me.dgvRealAlarm.AutoGenerateColumns = False
    End Sub


    ''' <summary>
    ''' 初始化设备和端口
    ''' </summary>
    Private Sub InitDevicesAndPorts()

#If DEBUG Then
        Dim dt As Double = DateTime.Now.Ticks
        Console.WriteLine("Start Load Device And Ports")
#End If

        _Devices = New Hashtable()

        ''=============================
        '' 获取全局报警

        Try
            Dim ds As DataSet = Nothing
            Dim dal As CcapSetPortService = New CcapSetPortService
            '' A.Id,A.DevId,B.csNetId,A.CpsLostPowerAlarmPort, A.CpsBreakDownAlarmPort
            ds = dal.GetPorts(_ProjectId)
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                Dim dr As DataRow = ds.Tables(0).Rows(0)
                AddToHashTable(CInt(dr(2)), CInt(dr(3)), "", "系统断电")
                AddToHashTable(CInt(dr(2)), CInt(dr(4)), "", "发电机启动故障保护")
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加全局报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

        ''=============================
        '' 冷凝机组报警
        Try
            Dim dal As CcapCondenserSetPortService = New CcapCondenserSetPortService()
            Dim ds As DataSet = Nothing
            ds = dal.GetGroupNameAndPorts(_ProjectId)
            ''Id,csId,csNetId,csName,CsLostPowerAlarmPort,CsOverLoadAlarmPort,CsBreakDownAlarmPort
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                For Each dr As DataRow In ds.Tables(0).Rows
                    AddToHashTable(CInt(dr(2)), CInt(dr(4)), CStr(dr(3)), "缺项保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(5)), CStr(dr(3)), "过载保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(6)), CStr(dr(3)), "故障保护")
                Next
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加冷凝机组报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

        ''==========================
        '' 并联机组
        Try
            Dim dal As CcapCompressorSetPortItemService = New CcapCompressorSetPortItemService()
            Dim ds As DataSet = Nothing
            ds = dal.GetGroupNameAndPorts(_ProjectId)
            ''`Id`,csId,csNetId,csName,csSuckPressAlarmPort,csLowLiquidAlarmPort,CsLostPowerAlarmPort
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                For Each dr As DataRow In ds.Tables(0).Rows
                    AddToHashTable(CInt(dr(2)), CInt(dr(4)), CStr(dr(3)), "吸气压力保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(5)), CStr(dr(3)), "低液位保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(6)), CStr(dr(3)), "缺项保护")
                Next
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加并联机组报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

        ''==========================
        '' 压缩机
        Try
            Dim dal As CcapCompressorPortItemServices = New CcapCompressorPortItemServices()
            Dim ds As DataSet = Nothing
            ds = dal.GetGroupNameAndPorts(_ProjectId)
            '' Id,csId,csNetId,name,cpLowPressAlarmPort,cpHighPressAlarmPort,cpOileAlarmPort,cpChargeTAlarmPort,cpOverLoadAlarmPort
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                For Each dr As DataRow In ds.Tables(0).Rows

                    AddToHashTable(CInt(dr(2)), CInt(dr(4)), CStr(dr(3)), "低压保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(5)), CStr(dr(3)), "高压保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(6)), CStr(dr(3)), "油压保护")
                    AddToHashTable(CInt(dr(2)), CInt(dr(7)), CStr(dr(3)), "排气温度", True)
                    AddToHashTable(CInt(dr(2)), CInt(dr(8)), CStr(dr(3)), "过载保护")
                Next
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加压缩机报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

        ''==========================
        '' 冷凝器
        Try
            Dim dal As CcapCondenserPortItemService = New CcapCondenserPortItemService()
            Dim ds As DataSet = Nothing
            ds = dal.GetGroupNameAndPorts(_ProjectId)
            '' Id, ceId, csNetId, name, cePressPreAlarmPort
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                For Each dr As DataRow In ds.Tables(0).Rows
                    AddToHashTable(CInt(dr(2)), CInt(dr(4)), CStr(dr(3)), "冷凝压力保护")
                Next
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加冷凝器报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

        ''==========================
        '' 冷风机
        Try
            Dim dal As CcapAirCoolerPortItemService = New CcapAirCoolerPortItemService()
            Dim ds As DataSet = Nothing
            ds = dal.GetGroupNameAndPorts(_ProjectId)
            '' Id, ceId, csNetId, name, acDefPreAlarmPort
            If (ds IsNot Nothing) AndAlso ds.Tables(0).Rows.Count > 0 Then
                For Each dr As DataRow In ds.Tables(0).Rows
                    AddToHashTable(CInt(dr(2)), CInt(dr(4)), CStr(dr(3)), "除霜故障保护")
                Next
            End If
        Catch ex As Exception
#If DEBUG Then
            System.Diagnostics.Debug.WriteLine("添加冷风机报警端口失败，原因：" + ex.Message + vbCrLf + " 堆栈：" + ex.StackTrace)
#End If
        End Try

#If DEBUG Then

        Console.WriteLine("end : Using {0} s", (DateTime.Now.Ticks - dt) / TimeSpan.TicksPerSecond)
#End If

    End Sub

    ''' <summary>
    ''' 添加端口到列表中
    ''' </summary>  
    ''' <remarks></remarks>
    Private Sub AddToHashTable(ByVal netId As Integer, ByVal port As Integer, ByVal devName As String, ByVal alarmName As String, Optional ByVal IsAI As Boolean = False)
        If (port = 0) Then Exit Sub
        If (port = 0) Then Exit Sub


        Dim dap As DeviceAndPort = New DeviceAndPort
        dap.AlarmName = alarmName
        dap.DeviceName = devName
        dap.Port = port
        dap.NetId = netId
        dap.IsAI = IsAI
        ''============================
        '' key: AI=Port + netId * 100 + 32
        '' key: DI=Port + netId * 100
        Try

            If (IsAI) Then
                _Devices.Add(netId * 100 + port + 32, dap)
            Else
                _Devices.Add(netId * 100 + port, dap)
            End If

        Catch ex As Exception
#If DEBUG Then
            If (IsAI) Then
                System.Diagnostics.Debug.WriteLine("添加端口失败！已经存在AI端口： " + port.ToString + " NETID：" + netId.ToString)
            Else
                System.Diagnostics.Debug.WriteLine("添加端口失败！已经存在DI端口：" + port.ToString + " NETID：" + netId.ToString)
            End If
            System.Diagnostics.Debug.Assert(ex.Message)
#End If
        End Try
    End Sub

    ''' <summary>
    ''' 处理双击事件
    ''' </summary>
    ''' <remarks>表示确认报警</remarks>
    Private Sub dgvRealAlarm_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvRealAlarm.CellDoubleClick
        '' 正在刷新数据时，不能进行确认数据。
        If (Me._IsRefreshing) Then
            Exit Sub
        End If

        '' 正在确认时也不能再次确认
        If (Me._IsConfirming) Then
            Exit Sub
        End If

        Try
            _IsConfirming = True
            ConfirmAlarm()
        Catch ex As Exception
            System.Diagnostics.Debug.WriteLine(ex.ToString())
            MessageBox.Show("报警确认失败！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        Finally
            _IsConfirming = False
        End Try
    End Sub

    ''' <summary>
    ''' 处理数据源错误
    ''' </summary>
    Private Sub dgvRealAlarm_DataError(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgvRealAlarm.DataError
        e.ThrowException = False
        Me.dgvRealAlarm.DataSource = Nothing
        Me.dgvRealAlarm.Refresh()
    End Sub


    ''' <summary>
    ''' 窗体加载
    ''' </summary>
    Private Sub FrmRealAlarm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AlarmStatustip.Visible = False
        Me.Timer1.Start()
    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If _IsColsing Then
            '' 窗体正在关闭
            Exit Sub
        End If
        If _IsConfirming Then
            '' 正在发送确认数据
            Exit Sub
        End If


        Me.Timer1.Stop()
        Try
            _IsRefreshing = True
            RefreshData()
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        Finally
            _IsRefreshing = False
        End Try
        Me.Timer1.Start()
    End Sub

    ''' <summary>
    ''' 刷新数据
    ''' </summary>
    Private Sub RefreshData()
        Me.lblTip.Text = "正在读取数据..."

        Try
            _DataSource.Rows.Clear()
            ''======================
            '' 读取数据
            _Buf = COMHelper.Instance.Send4Byte(_DevNetID, FunctionCode.WordReadonly, _offset, _DataLength)

            ''======================
            '' 不存在数据则直接返回
            If _Buf IsNot Nothing Then
                '' 清除读取失败次数
                _FailCount = 0
                AlarmStatustip.Visible = False
                ''======================
                '' 分析数据        
                For i As Integer = 0 To _MaxCount - 1
                    Dim iMonth As Integer = 0
                    Dim iDay As Integer = 0
                    Dim iHour As Integer = 0
                    Dim iMinute As Integer = 0
                    Dim iSecond As Integer = 0
                    Dim strTime As String = String.Empty
                    Dim netId As Integer = 0

                    netId = _Buf(i * _RecordSize + 0)       '' 网络地址

                    iMonth = _Buf(i * _RecordSize + 1)
                    iDay = _Buf(i * _RecordSize + 2)
                    iHour = _Buf(i * _RecordSize + 3)
                    iMinute = _Buf(i * _RecordSize + 4)
                    iSecond = _Buf(i * _RecordSize + 5)

                    '' 检测数据是否有效
                    If iMonth = 0 OrElse iDay = 0 OrElse iMonth = 255 OrElse iDay = 255 Then
                        Continue For
                    Else
                        strTime = String.Format("{0}-{1} {2}:{3}:{4}", iMonth, iDay, iHour, iMinute, iSecond)
                    End If

                    Dim iType As Integer = 0
                    Dim iLevel As Integer = 0
                    Dim iValidate As Integer = 0
                    Dim iConfirmed As Integer = 0
                    iType = _Buf(i * _RecordSize + 6)
                    iLevel = _Buf(i * _RecordSize + 7)
                    iValidate = _Buf(i * _RecordSize + 8)
                    iConfirmed = _Buf(i * _RecordSize + 9)

                    AddToTable(netId, iType, iLevel, iValidate, iConfirmed, strTime)
                Next i

                '' 绑定数据
                Dim irow As Integer = 0
                If Me.dgvRealAlarm.SelectedRows.Count > 0 Then
                    irow = Me.dgvRealAlarm.SelectedRows(0).Index
                End If

                Me.dgvRealAlarm.DataSource = Nothing
                Dim datasource As DataTable = _DataSource.Copy



                Me.dgvRealAlarm.DataSource = datasource
                SetColors()
                If Me.dgvRealAlarm.RowCount > irow Then
                    Me.dgvRealAlarm.Rows(irow).Selected = True
                End If
                Me.dgvRealAlarm.Refresh()

            Else
                '' 统计失败次数
                _FailCount += 1
                If (_FailCount >= 5) Then
                    Me.dgvRealAlarm.DataSource = Nothing
                    AlarmStatustip.Visible = True
                End If
            End If
        Catch ex As Exception
            Debug.WriteLine(ex.ToString())
        End Try

        Me.lblTip.Text = ""
    End Sub

    Private Sub AddToTable(ByVal netId As Integer, ByVal iType As Integer, ByVal iLevel As Integer, ByVal iValidate As Integer, ByVal iConfirmed As Integer, ByVal strTime As String)
        Dim dr As DataRow
        Dim iPort As Integer = 0
        Dim strAlarm As String = String.Empty
        Dim dap As DeviceAndPort


        ''=================================
        '' 分析itype

        ''=================================
        '' 增加兼容DI数据报警
        If (iType > 219) Then
            '' 第P个DI端口的数据报警
            '' 210+P-1	.Alarm_Type报警代码类型		第P个DI端口的数据报警；       (P表示EX控制器的DI端口编号,范围:1-32)	
            iPort = iType - 210 + 1
            If Me._Devices.ContainsKey(netId * 100 + iPort) Then
                dap = _Devices(netId * 100 + iPort)
                strAlarm = "报警"
            Else
                Exit Sub
            End If

        ElseIf iType > 169 Then '' 取消了 iType > 169 And iType < 187
            '' 是DI报警
            '' 170+M-1	.Alarm_Type报警代码类型		第M个DI端口的数据预警；       (M表示EX控制器的DI端口编号,范围:1-32)					
            iPort = iType - 170 + 1
            ' System.Diagnostics.Debug.WriteLine(iPort)
            If Me._Devices.ContainsKey(netId * 100 + iPort) Then
                dap = _Devices(netId * 100 + iPort)
                strAlarm = "预警"
            Else
                Exit Sub
            End If

        ElseIf iType > 99 Then  '' 取消了 iType < 137 And iType > 99 条件
            '' 是AI 
            '' 100+(N-1)*4 +0	.Alarm_Type报警代码类型		第N个AI端口的数据超低限预警； (N表示EX控制器的AI端口编号,范围:1-16)					
            '' 100+(N-1)*4+1	.Alarm_Type报警代码类型		第N个AI端口的数据超高限预警；					
            '' 100+(N-1)*4+2	.Alarm_Type报警代码类型		第N个AI端口的数据超低限报警；					
            '' 100+(N-1)*4+3	.Alarm_Type报警代码类型		第N个AI端口的数据超高限报警；		
            iPort = Math.Floor((iType - 100) / 4) + 1

            If (Me._Devices.ContainsKey(netId * 100 + iPort + 32)) Then
                dap = _Devices(netId * 100 + iPort + 32)
            Else
                Exit Sub
            End If

            Select Case (iType - 100) Mod 4
                Case 0
                    strAlarm = "超低限预警"
                Case 1
                    strAlarm = "超高限预警"
                Case 2
                    strAlarm = "超低限报警"
                Case 3
                    strAlarm = "超高限报警"
            End Select
        Else
            '' 展示不处理小于100 的情况
            Exit Sub
        End If

        dr = _DataSource.NewRow
        dr(0) = dap.NetId
        dr(1) = dap.Port
        dr(2) = dap.IsAI
        dr(3) = strTime
        dr(4) = dap.DeviceName + "|" + dap.AlarmName + "|" + strAlarm
        '' 1严重；2一般；3警告
        Select Case iLevel
            Case 1
                dr(5) = "严重"
            Case 2
                dr(5) = "一般"
            Case 3
                dr(5) = "警告"
            Case Else
                dr(5) = "一般"
        End Select

        dr(6) = IIf(iValidate = 2, True, False)
        dr(7) = IIf(iConfirmed = 2, True, False)
        dr(8) = iType
        _DataSource.Rows.Add(dr)
    End Sub

    ''' <summary>
    ''' 初始化表结构
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub InitDataSource()
        _DataSource = New DataTable
        Dim col As DataColumn = New DataColumn()
        col.ColumnName = "NetID"
        col.DataType = New Integer().GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "PortID"
        col.DataType = New Integer().GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "IsAI"
        col.DataType = New Boolean().GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "StartTime"
        col.DataType = New String("").GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "DeviceName"
        col.DataType = New String("").GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "levelName"
        col.DataType = New String("").GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "IsValid"
        col.DataType = New Boolean().GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "confirmed"
        col.DataType = New Boolean().GetType
        _DataSource.Columns.Add(col)

        col = New DataColumn()
        col.ColumnName = "iType"
        col.DataType = New Integer().GetType
        _DataSource.Columns.Add(col)
    End Sub

    ''' <summary>
    ''' 设置颜色
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetColors()
        Try
            For Each row As DataGridViewRow In Me.dgvRealAlarm.Rows
                '报警有效的记录显示为红色，有效预警为橙色
                row.DefaultCellStyle.ForeColor = Color.Black

                If row.Cells("IsValid").Value Then
                    If (row.Cells("DeviceName").Value.ToString().LastIndexOf("报警") > 0) Then
                        row.DefaultCellStyle.ForeColor = Color.Red
                    ElseIf (row.Cells("DeviceName").Value.ToString().LastIndexOf("预警") > 0) Then
                        row.DefaultCellStyle.ForeColor = Color.Orange
                    End If
                End If

                '报警未确认的记录显示灰色背景颜色
                If (row.Cells("confirmed").Value) Then
                    row.DefaultCellStyle.BackColor = Color.LightGray
                Else
                    row.DefaultCellStyle.BackColor = Color.White
                End If

            Next
        Catch ex As Exception

        End Try
    End Sub


    Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
        _IsColsing = True
        MyBase.OnClosing(e)
    End Sub

    Private Sub btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAll.Click
        If (Me.dgvRealAlarm.RowCount = 0) Then
            MessageBox.Show("未有待确认报警", "系统提示", MessageBoxButtons.OK)
            Exit Sub
        End If

        Dim result As Boolean
        _IsConfirming = True

        If DialogResult.No = MessageBox.Show("确定要确认所有报警？", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) Then
            _IsConfirming = False
            Exit Sub
        End If

        result = AlarmConfirmAll()
        _IsConfirming = False

        If result Then
            For Each row As DataGridViewRow In Me.dgvRealAlarm.Rows
                row.Cells("confirmed").Value = True
            Next

            SetColors()
        End If
    End Sub

    ''' <summary>
    ''' 清除所有报警标志
    ''' </summary>  
    Private Function AlarmConfirmAll() As Boolean
        Dim offset As UShort = 7068
        Dim value As Short = 2
        Try
            Return COMHelper.Instance.Write(_DevNetID, FunctionCode.WordWrite, offset, value)
        Catch ex As Exception
            Debug.WriteLine(ex.ToString())
            Return False
        End Try
    End Function

    ''' <summary>
    ''' 确认单个报警
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ConfirmAlarm()

        ''======================
        '' 检测是否存在选择的行
        If (Me.dgvRealAlarm.CurrentRow Is Nothing) Then
            Exit Sub
        End If

        ''=======================
        '' 检测是否已经确认过
        If (Me.dgvRealAlarm.CurrentRow.Cells("confirmed").Value = True) Then
            Exit Sub
        End If

        Dim msg As String = String.Empty
        Dim netId As Integer

        Try
            msg = Me.dgvRealAlarm.CurrentRow.Cells("DeviceName").Value.ToString()
            netId = CInt(Me.dgvRealAlarm.CurrentRow.Cells("NetID").Value)
            If DialogResult.No = MessageBox.Show("是否要确认【" + msg + "】", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) Then
                Exit Sub
            End If
            ''======================
            '' 确认报警
            Dim offset As UShort = 7069
            Dim iType As Integer = 0
            iType = CInt(Me.dgvRealAlarm.CurrentRow.Cells("iType").Value)

            '' 高8位为网络地址，低8位为报警类型
            Dim value As Short = netId * 2 ^ 8 + iType
            If (COMHelper.Instance.Write(_DevNetID, FunctionCode.WordWrite, offset, value)) Then
                Me.dgvRealAlarm.CurrentRow.Cells("confirmed").Value = True
                Me.dgvRealAlarm.CurrentRow.DefaultCellStyle.BackColor = Color.White
            Else
                MessageBox.Show("确认报警失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End If
        Catch ex As Exception
            MessageBox.Show("确认报警失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Try
    End Sub
End Class